package ru.cod.rs.objects.gameobjects;

import ru.cod.rs.objects.Direction;

public class Velocity {

	private int value;
	private Direction dir;
	private Direction dirCache;

	public Velocity(int val, Direction d) {
		dir = d;
		dirCache = dir;
		value = val;
	}

	public int value() {
		return value * dir.value();
	}

	public void switchDir() {
		if (dir.equals(Direction.Right)) {
			dir = dirCache = Direction.Left;
		} else if (dir.equals(Direction.Left)) {
			dir = dirCache = Direction.Right;
		}
	}

	public void resume() {
		if (dir.equals(Direction.NONE)) {
			dir = dirCache;
		}
	}

	public void setDirection(Direction dir) {
		this.dir = dirCache = dir;
	}
}
